<template>
	<view class="all-main">
		<view class="main">
			<view class="logo">
				<image src="@/static/logo.png"></image>
				<view class="titles">
					<text>欢迎使用事成物流</text>
				</view>
			</view>
			<view class="forms">
				<view class="form-item">
					<view class="texts">
						<text>手机号</text>
					</view>
					<view class="form-input">
						<input type="number" v-model="phone" placeholder="请输入手机号" />
					</view>
				</view>
				<view v-if="login_types==1" class="form-item">
					<view class="texts">
						<text>密码</text>
					</view>
					<view class="form-input">
						<input type="password" v-model="password" placeholder="请输入密码" />
					</view>
				</view>
				<view v-else class="form-item">
					<view class="texts">
						<text>验证码</text>
					</view>
					<view class="form-input yzm">
						<input type="text" v-model="code" placeholder="请输入验证码" />
						<view class="yzm-btn">
							<text>获取验证码</text>
						</view>
					</view>
				</view>
			</view>
			<view class="submit-btn" @tap="login">
				<text>登录</text>
			</view>
			<view class="agreement">
				<label>
					<checkbox :value="agreement" />
				</label>
				<view class="agreement-text">
					<text>已阅读并同意</text>
					<text class="blues" @tap="agreement_to(1)">用户协议</text>
					<text class="blues">、</text>
					<text class="blues" @tap="agreement_to(2)">隐私政策</text>
				</view>
			</view>
			<view class="bottoms">
				<view class="left">
					<text @tap="register">立即申请</text>
				</view>
				<view class="right" @tap="login_type">
					<text>{{login_text}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				password: '',
				code: '',
				agreement: 1,
				login_text: '验证码登录',
				login_types: 1,
			};
		},
		onLoad() {
			
		},
		methods: {
			// 切换登录方式
			login_type() {
				if (this.login_types == 1) {
					this.login_types = 2
					this.login_text = '密码登录'
				} else {
					this.login_types = 1
					this.login_text = '验证码登录'
				}
			},
			// 协议
			agreement_to(type) {
				uni.navigateTo({
					url: '/pages/login/agreement?type=' + type
				})
			},
			// 注册
			register() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
			// 登录
			login() {
				uni.navigateTo({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff !important;
	}

	.all-main {
		.main {
			padding: 50rpx;

			.logo {

				image {
					width: 160rpx;
					height: 160rpx;
				}

				.titles {
					padding-top: 20rpx;
					font-size: 60rpx;
					font-weight: bold;
				}
			}

			.forms {
				margin-top: 60rpx;

				.form-item {
					margin-bottom: 50rpx;

					.texts {
						font-size: 28rpx;
					}

					.form-input {
						padding-top: 20rpx;
						border-bottom: 1px solid #c8c9cc;

						input {
							padding: 20rpx 0;
						}
					}

					.yzm {
						display: flex;
						justify-content: space-between;
						align-items: center;
						input {
							width: 50%;
						}
						
						.yzm-btn {
							background-color: #2979ff;
							color: #ffffff;
							padding: 16rpx 20rpx;
							margin-bottom: 15rpx;
							border-radius: 10rpx;
						}
					}
				}
			}
		
			.submit-btn {
				margin: 30rpx 0;
				background-color: #2979ff;
				color: #ffffff;
				text-align: center;
				padding: 20rpx;
				border-radius: 10rpx;
			}
		
			.agreement {
				display: flex;
				align-items: center;
				.agreement-text {
					margin-left: 10rpx;
					font-size: 24rpx;
					
					.blues {
						color: #2979ff;
					}
				}
			}
		
			.bottoms {
				margin-top: 150rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				text-align: center;
				color: #909399;
				
				.left {
					width: 49.5%;
					border-right: 1px solid #909399;
				}
				
				.right {
					width: 49.5%;
				}
			}
		}
	}
</style>